<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('个人咨询')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>姓名：</label>
                                <input type="text" name="xingming"/>
                            </li>
                            <li>
                                <label>联系方式：</label>
                                <input type="text" name="lianxifangshi"/>
                            </li>
                            <li>
                                <label>是否公开：</label>

                            </li>
                            <li>
                                <select name="zhuangtai" class="form-control">
                                    <option value="">--请选择--</option>
                                    <option value=1>公开</option>
                                    <option value=0>未公开</option>
                                </select>
                            </li>


                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
<!--                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:guestbook:add">-->
<!--                    <i class="fa fa-plus"></i> 添加-->
<!--                </a>-->
<!--                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="system:guestbook:edit">-->
<!--                    <i class="fa fa-edit"></i> 修改-->
<!--                </a>-->
<!--                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:guestbook:remove">-->
<!--                    <i class="fa fa-remove"></i> 删除-->
<!--                </a>-->
<!--                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:guestbook:export">-->
<!--                    <i class="fa fa-download"></i> 导出-->
<!--                </a>-->
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('system:guestbook:edit')}]];
        var removeFlag = [[${@permission.hasPermi('system:guestbook:remove')}]];
        var prefix = ctx + "system/guestbook";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "反馈意见",
                columns: [{
                    checkbox: true
                },

                {
                    field: 'xingming',
                    title: '姓名'
                },
                {
                    field: 'lianxifangshi',
                    title: '联系方式'
                },
                {
                    field: 'liuyan',
                    title: '留言'
                },
                {
                    field: 'shifougongkai',
                    title: '状态'
                },
                {
                    field: 'text2',
                    title: '回复'
                },

                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.guestbookid + '\')"><i class="fa fa-edit"></i>回复</a> ');
                        actions.push('<a class="btn btn-primary btn-xs ' + editFlag + '" href="javascript:void(0)"  onclick="updatezhuangtai(\'' + row.guestbookid + '\''+','+1+')"><i class="fa fa-edit"></i>确认公开</a> ');
                        actions.push('<a class="btn btn-warning btn-xs ' + editFlag + '" href="javascript:void(0)"  onclick="updatezhuangtai(\'' + row.guestbookid + '\''+','+0+')"><i class="fa fa-edit"></i>取消公开</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.guestbookid + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
        function updatezhuangtai(ppId,shifougongkai){

            $.ajax({
                type: "post",
                url:  "/system/guestbook/updatezhuangtai",
                data: {
                    "guestbookid": ppId,
                    "zhuangtai":shifougongkai
                },
                success: function(r) {
                    if (r.code == 0) {
                        alert("更新成功");
                        $.table.search();
                    } else {
                        alert(r.msg);
                    }
                }
            });
        }
    </script>
</body>
</html>